package com.sg.business.vault.editor;

import org.bson.types.ObjectId;

import com.mobnut.db.model.PrimaryObject;
import com.sg.business.model.Folder;
import com.sg.business.resource.nls.Messages;
import com.sg.widgets.viewer.ChildPrimaryObjectCreator;

public class FolderCreater extends ChildPrimaryObjectCreator {

	@Override
	protected String getMessageForEmptySelection() {
		return Messages.get().FolderCreater_0;
	}

	@Override
	protected void setParentData(PrimaryObject po) {
		PrimaryObject parent = po.getParentPrimaryObjectCache();
		ObjectId parentId;
		ObjectId rootId;

		 if (parent instanceof Folder) {
			parentId = parent.get_id();
			rootId = ((Folder) parent).getRoot_id();
		} else {
			return;
		}
		po.setValue(Folder.F_PARENT_ID, parentId);
		po.setValue(Folder.F_ROOT_ID, rootId);

	}

}
